<script>
$(function() {

	$('.submit').css
	$('#add_gallery').click(function() {
		$('#add_gallery_dialog').dialog({
			title: "upload image",
			width: 500,
			height: 500,
			dragable: false,
			resizable: false,
			modal: true,
			
		});
	});
});

</script>

<!--------------------------------------------------------------------------------->


<div class="events index">
	    
    <h2><?php __('Photo Galleries'); ?></h2>
   
  
    
    <table>
		<tr>
			<td class="actions">
				<?php echo $this->Html->link('Add Gallery', '#', array('id'=>'add_gallery'))?>
				<div id="add_gallery_dialog" style="display: none;">
				<?php echo $this->Form->create('Gallery', array('action'=>'add_gallery','enctype' => 'multipart/form-data'));?>
   				
				<?php
	    			echo $this->Form->input('name');
    				echo $form->input('description', array('label'=>'Gallery Description:'));
    				echo $form->input('image',array('label'=>'Gallery Image', 'type'=>'file'));?>
    				<input type="submit" value="Create" style="float:right;">
    				<?php echo $this->Form->end();?>
				</div>
			</td>
		</tr>
	</table>

   	
   	<?php if ($galleries):?>
   	<?php foreach ($galleries as $gallery):?>
   		<div class='galleries_displaying'><a href="galleries/view_gallery/<?php echo $gallery['Gallery']['id'];?>">
   		<?php if (file_exists('img/gallery/' . $gallery['Gallery']['id']. '.jpg')) {
           		echo '<p>' . $this->Html->image('gallery/' . $gallery['Gallery']['id']. '.jpg', array('width' => '100')) . '</p>';
           	} else {
           		echo '<p>' . $html->image("default_user.jpg", array('width' => '100')) . '</p>';
           	}
           	echo "<p id='galleries_displaying_text'>" . $gallery['Gallery']['name'] . "</p>";
          ?>
          </a> </div>
   	<?php endforeach; ?> 
   	<?php endif; ?>
   
</div>

